/*
 * SectionPagerAdater.java
 * classes : com.ruint.lib.mediachooser.adapter.SectionPagerAdater
 * @author ruint
 * V 1.0.0
 * Create at 2014-12-11 上午10:29:25
 */
package com.ruint.lib.mediachooser.adapter;

import java.util.List;

import com.ruint.lib.mediachooser.fragment.TouchImageFragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * com.ruint.lib.mediachooser.adapter.SectionPagerAdater
 * 
 * @author ruint <br/>
 *         create at 2014-12-11 上午10:29:25
 */
public class SectionPagerAdater<T> extends FragmentPagerAdapter {

  private List<T> mList;

  public SectionPagerAdater(FragmentManager fm) {
    super(fm);
  }

  @Override
  public Fragment getItem(int position) {
    return TouchImageFragment.newInstance((String) mList.get(position));
  }

  @Override
  public int getCount() {
    return mList == null ? 0 : mList.size();
  }

  public void build(List<T> data) {
    mList = data;
    notifyDataSetChanged();
  }
}
